package com.epalmpay.controller.channel.ys.profit;

import com.epalmpay.commom.BaseController;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.status.Rescode;
import com.epalmpay.dto.yunliu.profit.*;
import com.epalmpay.service.ys.profit.IYsProfitService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping(value="/merchant/ys/profit")
public class ObdProfitController extends BaseController {
     
	@Resource
	private IYsProfitService ysProfitService;

	@RequestMapping(value="/obdProfitList")
	@ResponseBody
	public ObdProfitListListOutDTO obdProfitList(@RequestBody ObdProfitListInDTO inDTO){
		ObdProfitListListOutDTO outDTO = new ObdProfitListListOutDTO();
		try {
			outDTO = ysProfitService.getObdProfitList(inDTO);
			outDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return outDTO;
		} catch (ApplicationException ae) {
			outDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
			logger.error(ae);
		}
		catch (Exception e) {
			outDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
			e.printStackTrace();
			logger.error(e);
		}
		return outDTO;
	}

	@RequestMapping(value="/obdProfitMonthList")
	@ResponseBody
	public YsProfitOutDTO obdProfitMonthList(@RequestBody ObdProfitListInDTO inDTO){
		YsProfitOutDTO outDTO = new YsProfitOutDTO();
		try {
			outDTO = ysProfitService.getObdProfitMonthList(inDTO);
			outDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return outDTO;
		} catch (ApplicationException ae) {
			outDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
			logger.error(ae);
		}
		catch (Exception e) {
			outDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
			e.printStackTrace();
			logger.error(e);
		}
		return outDTO;
	}

	@RequestMapping(value="/obdProfitDayList")
	@ResponseBody
	public YsProfitOutDTO obdProfitDayList(@RequestBody ObdProfitListInDTO inDTO){
		YsProfitOutDTO outDTO = new YsProfitOutDTO();
		try {
			outDTO = ysProfitService.getObdProfitDayList(inDTO);
			outDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return outDTO;
		} catch (ApplicationException ae) {
			outDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
			logger.error(ae);
		}
		catch (Exception e) {
			outDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
			e.printStackTrace();
			logger.error(e);
		}
		return outDTO;
	}

}
